#include "stdio.h"
#include "string.h"
#define Max 105
char s1[Max],s2[Max];
int  tq[200][2],len1,len2,len;
int  time1[Max],time2[Max];
int i,j,flag;

int main()
{
   scanf("%s",s1);
   scanf("%s",s2);
   len1=strlen(s1);
   len2=strlen(s2);
   if (len1!=len2)
   {
       printf("NO\n");
   }
   else
   {
       len=len1;
       memset(tq,0,sizeof(tq));
       memset(time1,0,sizeof(time1));
       memset(time2,0,sizeof(time2));
       
       for (i=0;i<len;i++)
       {
           tq[s1[i]][0]++;
           tq[s2[i]][1]++;
       }    
       flag=1;
       for (i='A';i<='Z';i++)
       {
           time1[tq[i][0]]++;
           time2[tq[i][1]]++;
       }           
       for (i=0;i<=100;i++)
              if( time1[i]!=time2[i])
              {
                  flag=0;
                  break;
              }    
       if (flag) printf("YES\n");
       else       printf("NO\n");
   }
return 0;
 
}    